package com.woniuxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.conmon.enums.RedisConst;
import com.woniuxy.mapper.GoodsTypeMapper;
import com.woniuxy.pojo.GoodsType;
import com.woniuxy.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 29331
* @description 针对表【t_goods_type】的数据库操作Service实现
* @createDate 2025-06-03 10:13:09
*/
@Service
public class GoodsTypeServiceImpl extends ServiceImpl<GoodsTypeMapper, GoodsType>
    implements GoodsTypeService {

    @Autowired
    GoodsTypeMapper goodsTypeMapper;

    @Override
    @Cacheable(cacheNames = RedisConst.GOODS_TYPE_LIST,keyGenerator = "keyGenerator")
    public List<GoodsType> getGoodsTypes() {

        return goodsTypeMapper.selectList(null);
    }

    @Override
    public String getTypeById(Long id) {
        LambdaQueryWrapper<GoodsType> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(GoodsType::getId,id);
        GoodsType goodsType = goodsTypeMapper.selectOne(wrapper);
        String name = goodsType.getName();

        return name;
    }
}




